package com.yxh.www.author.controller;


import com.yxh.www.author.api.AuthorSmAccountApiRelationApi;
import com.yxh.www.author.service.SmAccountApiRelationService;
import com.yxh.www.common.result.Result;
import io.swagger.annotations.Api;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统账户接口关系 前端控制器
 * </p>
 *
 * @author Yangxiaohui
 * @since 2020-05-09
 */
@Api(tags = "系统第三方账户接口关系管理")
@RestController
public class SmAccountApiRelationController implements AuthorSmAccountApiRelationApi {

    private final SmAccountApiRelationService smAccountApiRelationService;

    public SmAccountApiRelationController(SmAccountApiRelationService smAccountApiRelationService) {
        this.smAccountApiRelationService = smAccountApiRelationService;
    }

    /**
     * 增加第三方账户接口关系
     *
     * @param accountId 第三方账户ID
     * @param apiIds    接口ID集合
     * @return 统一响应 {@link Result}
     */
    @Override
    public Result<Object> addSmAccountApiRelation(String accountId, String[] apiIds) {
        return smAccountApiRelationService.addSmAccountApiRelation(accountId, apiIds);
    }

    /**
     * 根据关系ID集合删除 账户接口关系
     *
     * @param ids 关系ID集合
     * @return 统一响应 {@link Result}
     */
    @Override
    public Result<Object> removeSmAccountApiRelation(String[] ids) {
        return smAccountApiRelationService.removeSmAccountApiRelation(ids);
    }

    /**
     * 根据第三方账户ID删除 账户接口关系
     *
     * @param accountId 第三方账户ID
     * @return 统一响应 {@link Result}
     */
    @Override
    public Result<Object> removeSmAccountApiRelationByAccountId(String accountId) {
        return smAccountApiRelationService.removeSmAccountApiRelationByAccountId(accountId);
    }

    /**
     * 根据接口ID删除 账户接口关系
     *
     * @param apiId 接口ID
     * @return 统一响应 {@link Result}
     */
    @Override
    public Result<Object> removeSmAccountApiRelationByApiId(String apiId) {
        return smAccountApiRelationService.removeSmAccountApiRelationByApiId(apiId);
    }

    /**
     * 根据接口ID和账户ID删除 账户接口关系
     *
     * @param accountId 第三方账户ID
     * @param apiId     接口ID
     * @return 统一响应 {@link Result}
     */
    @Override
    public Result<Object> removeSmAccountApiRelationByAccountIdAndApiId(String accountId, String apiId) {
        return smAccountApiRelationService.removeSmAccountApiRelationByAccountIdAndApiId(accountId, apiId);
    }
}
